#include "head.h"

void* thread_main(void* argv){

    status_t* status = (status_t*)argv;

    while(1){

        int net_fd = 0;

        pthread_mutex_lock(&status->lock);
        while(status->q.size <= 0){

            pthread_cond_wait(&status->cond, &status->lock);

        }

        net_fd = status->q.head->net_fd;
        dequeue(&status->q);

        pthread_mutex_unlock(&status->lock);

        to_work(net_fd);

        close(net_fd);

    }

    return NULL;
}
